import Vue from 'vue';
import VueRouter from 'vue-router'
Vue.use(VueRouter);
import Home from '@/pages/Home';
import Login from '@/pages/Login'
import Register from '@/pages/Register'
import Search from '@/pages/Search'
const originPush=VueRouter.prototype.push;
VueRouter.prototype.push=function push(location){
    return originPush.call(this,location).catch(err=>err)
}
const originReplace=VueRouter.prototype.replace;
VueRouter.prototype.replace=function replace(location){
    return originReplace.call(this,location).catch(err=>err)
}
export default new VueRouter({
    routes:[
        {
            path:'/home',
            component:Home
        },
        {
            path:'/login',
            component:Login,
            meta:{
                isHide:true
            }
        },
        {
            path:'/register',
            component:Register,
            meta:{
                isHide:true
            }
        },
        {   
            name:'search',
            path:'/search/:keyword?',
            component:Search
        },
        {
            path:'/',
            redirect:'/home'
        }
    ]
})